package com.converter.api;

import com.converter.pdfConverter.OpenOfficePDFConverter;
import com.converter.pdfConverter.PDFConverter;
import com.converter.swfConverter.SWFConverter;
import com.converter.swfConverter.SWFToolsSWFConverter;

public class ConverterAPI {
	public static String dirRoot="D:/g305_upload_file/resource/";
	public static boolean convert(String filename){
		String str=filename.substring(0,filename.indexOf("."));
		String sourcePath=dirRoot+"source/"+filename;
		String pdfPath=dirRoot+"pdf/"+str+".pdf";
		String swfPath= dirRoot+"swf/"+str+".swf";
		boolean flag=true;
		try{
			PDFConverter pdfConverter=new OpenOfficePDFConverter();
			pdfConverter.convert2PDF(sourcePath, pdfPath);
			SWFConverter swfConverter=new SWFToolsSWFConverter();
			swfConverter.convert2SWF(pdfPath,swfPath);
		}catch(Exception exception){
			flag=false;
		}
		return flag;
	}
	
	public static void main(String[] argStrings){
		boolean flag=convert("201209071347022616462.doc");
		System.out.print(flag);
	}

}
